#pragma once
// 机器人公用的负载设置
#include <stdint.h>
#include <string>
#include <memory>

namespace Util {
class IniParser;
}

namespace axisgroup {

class RobotPayloadMgr;

class RobotPayload
{
public:
    struct Payload
    {
        double m = 0;  // kg
        double p[3];   // mm
    };

public:
    RobotPayload(uint32_t id);
    RobotPayload();
    ~RobotPayload() = default;
    const Payload& payload() const { return payload_; }
    void config_payload(Payload payload, std::string name);
    void config_payload(Payload payload);
    void reset();
    std::string get_payload_descript() const;

private:
    uint32_t id_ = 0;
    std::string name_ = "";
    Payload payload_;
    bool is_changed_ = false;

    friend RobotPayloadMgr;
};

class RobotPayloadMgr
{
public:
    RobotPayloadMgr() = delete;
    const static uint32_t MAX_ROBOT_PAYLOAD_NUM = 10;
    static RobotPayload& get_robot_payload(uint32_t id);
    static int init_rob_payload(const char* filename);
    static void save();

private:
    static std::unique_ptr<Util::IniParser> ini_parser_;
    static RobotPayload __robot_payload[MAX_ROBOT_PAYLOAD_NUM];
};

}  // namespace axisgroup